RUN-4466: Block cross-origin HTTP redirects to prevent credential exfiltration - #609
Merged
Merged
Conversation
…iltration Add CrossOriginRedirectInterceptor as a network interceptor that aborts any 3xx redirect whose Location resolves to a different scheme, host, or port than the original request URL. This prevents authentication credentials (X-Rundeck-Auth-Token header, j_username/j_password form body) from being leaked to attacker-controlled hosts via malicious redirects. Default behavior: cross-origin redirects throw IOException with a clear message including the blocked URL. Opt-in to original behavior via: - RD_ALLOW_CROSS_ORIGIN_REDIRECT=true environment variable - --allow-cross-origin-redirect CLI flag A warning is printed to stderr when the opt-in is active. Fixes HackerOne report #3655293. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Declare the flag as a @option on Main so picocli accepts it during argument parsing. Without this, picocli threw 'Unknown option' even though the pre-processing logic in main() already handled it. Add MainSpec covering flag recognition, default-false behaviour, and the system property pre-processing logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Jesus-Osuna-M
approved these changes
May 20, 2026
Jesus-Osuna-M
left a comment
Contributor
There was a problem hiding this comment.
Tested and verified the fix manually against a live staging RBA instance (v5.21). The CrossOriginRedirectInterceptor correctly blocks cross-origin redirects by default — confirmed the token leak on main (no fix) and the block on this branch. Opt-in via RD_ALLOW_CROSS_ORIGIN_REDIRECT=true and --allow-cross-origin-redirect both work correctly with a visible warning. No regressions found in normal same-origin CLI operations. LGTM ✅
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a credential exfiltration vulnerability (HackerOne #3655293) where
rd-cli-toolwould forward authentication credentials to redirect targets without checking if they were on a different origin.CrossOriginRedirectInterceptoras a network interceptor that aborts 3xx redirects to a different scheme/host/portIOExceptionnaming the blocked URLRD_ALLOW_CROSS_ORIGIN_REDIRECT=trueor--allow-cross-origin-redirectCLI flag (prints a security warning)Affected authentication modes
X-Rundeck-Auth-Tokenheader no longer leaked on cross-origin redirectj_username/j_passwordform body no longer leaked via 307 redirectChanges
CrossOriginRedirectInterceptor.java— new network interceptor (blocks/allows based on config)RundeckClient.java— registers the interceptor; addsRD_ALLOW_CROSS_ORIGIN_REDIRECTenv var constant and builder methodMain.java— adds--allow-cross-origin-redirectCLI flag; shows security warning when opt-in is activeCrossOriginRedirectInterceptorSpec.groovy— 11 Spock unit tests covering all acceptance criteriaTest plan
./gradlew test)CrossOriginRedirectInterceptorSpec: 302/307 to different host/scheme/port blocked by defaultReferences
🤖 Generated with Claude Code